<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;

$this->title = '个人支付宝支付配置';
$this->params['breadcrumbs'][] = $this->title;

?>
<!-- page title -->
<div class="page-title">
  <div>
    <h1><i class="fa fa-trophy"></i> 个人支付宝支付配置</h1>
    <ul class="breadcrumb side">
      <li><i class="fa fa-home fa-lg"></i></li>
      <li>支付管理</li>
      <li class="active"><a href="#">个人支付宝支付配置</a></li>
    </ul>
  </div>
</div>
<!-- page title end-->

<!-- page body start -->
<div class="card">
<?php $form = ActiveForm::begin(); ?>
    <?php
      if(isset($tip)&&$tip===true){
        if($model->hasErrors()){
    ?>
          <div class="alert alert-danger" role="alert">
            <?php
                foreach($model->getErrors("") as $key=>$value){
                  echo $value."<br>";
                }
            ?>
          </div>
    <?php
        }else{
    ?>
          <div class="alert alert-success" role="alert">个人支付宝支付配置成功！</div>
    <?php
        }
      }
    ?>
    <?= $form->field($model, 'count') ?>
    <?= $form->field($model, 'qrcodefile')->fileInput() ?>
    <?php
      if(!isset($model->qrcode)||(is_null($model->qrcode))||($model->qrcode=='')){
        echo Html::img(Url::base().'/uploads/qrcode_default.jpg',['width'=>200,'height'=>200,'id'=>'qrcode-preview','style'=>'margin-bottom:20px;']);
      }else{
        echo Html::img(Url::base().'/'.$model->qrcode,['width'=>200,'height'=>200,'id'=>'qrcode-preview','style'=>'margin-bottom:20px;']);
      }
    ?>
    <div class="animated-checkbox">
      <label class="semibold-text">
        <?= $form->field($model, 'disable')->checkbox(['label' => '<span class="label-text">关闭此支付</span>']) ?>
      </label>
    </div>


    <div class="form-group">
        <?= Html::submitButton('提交', ['class' => 'btn btn-warning']) ?>
    </div>

<?php ActiveForm::end(); ?>
</div>
<!-- page body end-->

<?php $this->beginBlock('upload-qrcode-js') ?>

$('#alipayconfigform-qrcodefile').change(function(){
  var fr=new FileReader();
  fr.onload=function(){
    var preview=this.result;
    $('#qrcode-preview').prop('src',preview);
  }
  fr.readAsDataURL(this.files[0]);
});

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['upload-qrcode-js'],\yii\web\View::POS_END); ?>
